﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MvcWebRole1.Models;

namespace MvcWebRole1.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            ViewBag.Message = "Modify this template to kick-start your ASP.NET MVC application.";

            return View();
        }

        public ActionResult About()
        {
            ViewBag.Message = "Your app description page.";

            return View();
        }

        public ActionResult Contact()
        {
            ViewBag.Message = "Your contact page.";

            return View();
        }

        public ActionResult Test()
        {
            using (var conn = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString))
            {
                conn.Open();
                using (SqlCommand command = new SqlCommand("SELECT TOP 2 * FROM Drink", conn))
                using (SqlDataReader reader = command.ExecuteReader())
                {
                    ViewBag.Message = @"Get All Drinks: ";
                    while (reader.Read())
                    {                        
                        //Console.WriteLine("{0} {1} {2}",
                        //reader.GetInt32(0), reader.GetString(1), reader.GetString(2));
                        ViewBag.Message += @"\n" + reader.GetInt32(0) + ": " + reader.GetString(1);
                    }
                    
                }
                //comments = conn.ExecuteMapperQuery<String>("select * from Comment");
            }
            //ViewBag.Message = "Test Page";
            Tests test = new Tests();
            return View();
        }
    }
}
